package com.atguigu.servlet;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/servlet6")
public class Servlet6 extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置响应行相关的API
        resp.setStatus(200);
//        resp.setHeader("aaa","valuea");

        String html = "<html><body><h1>Servlet6</h1></body></html>";
        resp.setContentType("text/html;charset=utf-8");
//        resp.setContentLength(100);
        resp.setContentLength(html.getBytes().length);
        PrintWriter writer = resp.getWriter();
        writer.write(html);

        //获得一个向响应体中输入二进制信息的字节输出流
//        ServletOutputStream outputStream = resp.getOutputStream();


    }
}
